package
{
	import cn.meike.net.BinarySocket;
	import cn.meike.net.MsgFactory;
	import cn.meike.net.NetEvent;
	import cn.meike.net.NetEventDispatcher;
	import cn.meike.net.NetEventTypes;
	import cn.meike.net.protocol.KylinMsg;
	import cn.meike.net.protocol.Macros;
	
	import flash.display.Sprite;
	
	public class GClient extends Sprite
	{
		private var m_ip:String = "127.0.0.1";
		private var m_port:int = 10010;
		
		private var m_BinarySocket:BinarySocket = null;
		private var m_NetEventDispatcher:NetEventDispatcher = null;
		
		public function GClient()
		{
			trace("GClient...");
			
			_init();
		}
		
		private function _init():void
		{
			if(null == m_NetEventDispatcher)
			{
				m_NetEventDispatcher = new NetEventDispatcher();
			}
			
			m_NetEventDispatcher.addEventListener(NetEventTypes.SOCKET_CONNECT,_onSocketConnectListener);
			
			m_NetEventDispatcher.addEventListener(NetEventTypes.MsgType_LoginServer_Request,_onLoginServer_Request);
			
			if(null == m_BinarySocket)
			{
				m_BinarySocket =  new BinarySocket(m_NetEventDispatcher);
			}
			
			m_BinarySocket.connectByHost(m_ip,m_port,0);
		}
		
		private function _onSocketConnectListener(e:NetEvent):void
		{
			var _msg:KylinMsg = MsgFactory.getLoginServer_Request(10001,1000001);
			m_BinarySocket.sendPackage(_msg);
		}
		
		private function _onLoginServer_Request(e:NetEvent):void
		{
			var _msg:KylinMsg = e.getMsg();
		}
		
	}
	
	
}



